#include "tree.h"
typedef struct node
{
    variable     *data;
    char    *key;
    struct node *next; //解决hash冲突
} Node;

typedef struct Hash
{
    char           node_count;
    unsigned int   hash_count;
    Node           **list;
}Map;

typedef struct var_list_tag
{
    Map *var;
    struct var_list_tag *next;
} VarList;

// 数组index
#define ArrayIndex(key,hash_count)	( key & (hash_count-1) )

// 返回 *Node
#define list(n,i)	( n[i] )

#define FindIndex(key, hash_count) ( ParseIndex(key, hash_count) )

// 检测字符串是否相等
#define EQUAL(s1,s2)	( strcmp(s1, s2) == 0 ) 

Map *CreateMap();

int SetValue(Map *format, variable * new, char * key);

variable *GetValue(Map *format, char *key);
void MapFree(Map *format);
void NodeFree(Node *list);

VarList * GetVarListMemory();
variable * GetMapValue(VarList *var_list, char * key, int is_exit);